<!doctype html>
<html lang="zh-CN">
{include file='base/header' /}

<body class="gray-bg">
<div class="middle-box text-center loginscreen">
    <div>
        <div>
            <h1 class="logo-name">BX</h1>
        </div>

        <h3>欢迎使用广州博学教育系统</h3>

        <form class="m-t my-login-form" role="form" method="post" onsubmit="return to_login()">
            <div class="form-group">
                <input type="text" name="user_name" class="form-control" placeholder="请输入账号" required="">
            </div>

            <div class="form-group">
                <input type="password" name="password" class="form-control" placeholder="请输入密码" required="">
            </div>

            <div class="form-group">
                <div class="input-group m-b">
                    <input type="text" name="captcha" class="form-control" placeholder="请输入验证码" required="" >
                    <span class="input-group-addon">
                        <img id="captcha" class="my-captcha" src="{:captcha_src()}" onclick="this.src='{:captcha_src()}'" />
                    </span>
                </div>
            </div>

            <button type="submit" class="btn btn-primary block full-width m-b">登 录</button>
        </form>

    </div>
</div>

<!-- Mainly scripts -->
{load href="/static/js/jquery.min.js" /}
{load href="/static/js/bootstrap.min.js" /}
{load href="/static/js/plugins/layer/layer.min.js" /}

<script>
    function to_login() {
        $.ajax({
            type: 'POST',
            url: 'index',
            dataType: 'JSON',
            data: $("form").serialize(),
            success: function (e) {
                if (e.code > 0) {
                    layer.msg(e.msg);
                    $("#captcha").click();  //验证码输入错误的时候点击刷新
                } else {
                    window.location.href = e.data.url;
                }
            }
        });
        return false;
    }
</script>
</body>

</html>
